#include "StdAfx.h"
#include "EqModule.h"

namespace equipment
{

EqModule::EqModule(void)
{
	::InitializeCriticalSection(&m_current_actions_map_lock);
}

EqModule::~EqModule(void)
{
	::DeleteCriticalSection(&m_current_actions_map_lock);
}

bool EqModule::IsBusy()
{
	::EnterCriticalSection(&m_current_actions_map_lock);
	bool is_busy = (m_current_actions_map.size() > 0);
	::LeaveCriticalSection(&m_current_actions_map_lock);
	return is_busy;
}

void EqModule::DefineAction(
	EQ_MODULE_ACTION action,
	int action_time           // millisecond
	)
{
	m_supported_action_map[action] = action_time;
}

int EqModule::RunAction(
	EQ_MODULE_ACTION action
	)
{
	if (m_supported_action_map.find(action) == m_supported_action_map.end())
		return RA_UNSUPPORTED_ACTION;

	return RA_SUCCESS;
}

}